/*
action creator模块
同步返回对象
异步返回函数
 */
import {INCREMENT, DECREMENT} from './action-types'

export const increment = (num) => ({type: INCREMENT, data: num});
export const decrement = (num) => ({type: DECREMENT, data: num});
// 异步action creator(返回一个函数)
export const incrementAsync = (num) => {
    return dispatch => {
        //异步代码
        setTimeout(function () {
            dispatch(increment(num));
        }, 1000);
    }
};